<script type="text/javascript" src="./script/new.js"></script>
<div style="margin-left: 0px;
    width: 960px;
    display: inline-block;
    min-height: 500px;
    bottom: 0;
    ">
    <div style="display: block;" id="_main-content-page">
        <div class="detail-dialog unH" style="text-align: center;width: 960px;height: auto">
            <div class="dialog-close-button id-detail-dialog-close-button hidden">
                <div class="dialog-close-x"></div>
            </div>
            <div class="detail-dialog-header" style="height: 82px;width: 960px;">
                <div class="detail-dialog-header" style="width: 100%">
                    <div class="detail-dialog-header-block" style="height: auto;padding: 0 0 0 2px">
                        <div class="title-tag-item-detail" style="width: 940px">
                            <h1 style="line-height: 78px">News</h1>
                        </div>
                    </div>
                </div>
            </div>
            <div class="detail-dialog-body" style="width: 960px;height: auto">
                <div class="detail-dialog-tab-pane" style="width: 960px;height: auto">
                    <div class="goog-tab-content ">
                        <div class="detail-dialog-tab-content id-detail-dialog-contact-tab-content">
                            <div style="padding: 0px 0" class="">
<?
if($_SESSION[ "authority"]!="admin" && false){
   include "../NIV/checkauthority.php"; 
}else{
    include './Module/newsModule.php';
    $module=new newsModule();
?>
<table class="table-data" style="width: 960px;margin-top: 0px">
    <tr>
        <th>ID</th>
        <th>Title</th>
        <th style="min-width: 100px">Category</th>
        <th style="min-width: 100px">Status</th>
        <th style="min-width: 120px">Insert</th>
        <th style="min-width: 120px">Update</th>
        <th style="min-width: 120px">#</th>
    </tr>
    <tr class="id-head-row inew">
        <td colspan="7">
            <a class="" href="?Unit=10_new_detail">
                <div class="new pt4 pb4">++ New</div>
            </a>
        </td>
    </tr>

<?
//organization
$no=0;
$gr="";
$p=$_REQUEST["page"]?$_REQUEST["page"]:1;
$n=50;
$category="4";
$data=$module->getNews_all($p, $n,$q,$type);
echo $module->error;
if($data==null){
    echo "<tr><td colspan='7' style='text-align:center'>No data to display</td></tr>";
}else foreach ($data as $r){
    $no++;
    
?>
    <tr class="id-head-row <?=$r["id"]?> <?=$r["delete"]?"cred":($r["status"]=="Public"?"cblue":"")?>">
        <td><?=$r["id"]?></td>
        <td><?=$r["title"]?></td>
        <td><?=$r["categoryname"]?></td>
        <td>
            <?
            if(!$r["delete"]){
            ?>
                <span class="showandhide">
                    <span class="hideifhover">
                    <?
                    if($r["status"]=="Private"){
                        echo "Private";
                    }else{
                        echo "Public";
                    }
                    ?>   
                    </span>
                    <span class="showifhover">
                    <?
                    if($r["status"]=="Private"){
                        echo "<a href=\"javascript:statusNew('".$r["id"]."','Public');\">Private → Public</a>";
                    }else{
                        echo "<a href=\"javascript:statusNew('".$r["id"]."','Private');\">Public → Private</a>";
                    }
                    ?>
                    </span>
                </span>
            <?
            }else echo $r["status"];
            ?>
        </td>
        <td><?=$r["insert"]?></td>
        <td><?=$r["update"]?></td>
        <td style="padding: 0;margin: 0;vertical-align: middle;">
            
            
            
                <?
                if($r["delete"]){
                ?>
                <div class="icon16 hover50 tooltip"
                        title="Restore"
                        onclick="restoreNew('<?=$r["id"]?>');"
                        >
                    <img src="./images/icon/gtk_undelete.png">
                    
                </div>
                <?    
                }else{
                ?>
            <span class="action" style="margin-top: 3px">
                <div class="icon16 hover50 tooltip"
                        title="Delete"
                        onclick="deleteNew('<?=$r["id"]?>');"
                        >
                    <img src="./images/icon/16/edit_delete.png">
                </div>
                <div class="icon16 hover50 tooltip"
                        title="Edit"
                        onclick=""
                        >
                    <a href="?Unit=10_new_detail&id=<?=$r["id"]?>" style="margin: 0;padding: 0">
                        <img src="./images/icon/16/document_edit.png">
                    </a>
                </div>
            </span>
                <?
                }
                ?>
            
                
        </td>
    </tr>
    <tr class="id-content-row <?=$r["id"]?> hidden">
        <td colspan="7">
            <center>đang tải...<br/>
                Nếu trang không tự tải nội dung hãy ấn vào 
                <a class="loadding" href="javascript:show_item('<?=$r["id"]?>','<?=$_REQUEST["type"]?>');">đây</a> để tải lại.<br/>
                Hoặc ấn vào <a href="02_Admin_planners.php?Unit=template_detail&id=<?=$r["id"]?>">đây</a> để tải tại tab khác.
            </center>
        </td>
    </tr>
<?
}
?>
</table>
<?
}
?>
<div class="clear"></div>


    
        <?
        $numrow=$module->getNew_NumRow_all();
        if($numrow/$n>1){
        $ps=($numrow%$n==0)?$numrow/$n:($numrow/$n)+1;
        ?>
<div class="grid_6">
    <div class="pl12 pr12 pt4 pb4">
        Page <?=$p?> / <?=$ps?>
    </div>
</div>
<div class="grid_18">     
    <div class="pl12 pr12 pt4 pb4">   
        <div class="carousel-pagination _fl">
            
            <a href="?Unit=09_new<?=($p-1>0)?"&page=1":""?>">
                <div p="<?=($p-1>0)?$p-1:""?>" class="carousel-pagination-button carousel-pagination-button-previous" ></div>
            </a>
            <?
            for($i=1;$i<=$ps;$i++){
            ?>
            <a href="?Unit=09_new<?=($i!=$p)?"&page=$i":""?>">
                <div p="<?=($i==$p)?"":"$i"?>" class="carousel-pagination-button <?=($i==$p)?"carousel-pagination-button-current":""?>"></div>
            </a>
            <?
            }
            ?>
            <a href="?Unit=09_new<?=($p+1<$ps)?"&page=".($p+1):""?>"><div p="<?=($p+1<$ps)?$p+1:""?>" class="carousel-pagination-button carousel-pagination-button-next"></div></a>
        </div>
    </div>
</div>
        <?
        }
        ?>
    

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>                  
    </div>
</div>
<script>
   
</script>